-
-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LOD management functions #3831
base: master
Are you sure you want to change the base?
Add LOD management functions #3831
Conversation
Server/mods/deathmatch/logic/luadefs/CLuaFunctionDefs.Server.cpp
Outdated
Show resolved
Hide resolved
The lod arrays from the map editor are incomplete, so I assume this function is also incomplete. Therefore, a note should be added on the wiki once this PR is merged |
No. I completed the table. It's good now. |
getObjectLODModel(int objectModel)
getObjectLODModel
and getObjectModelOfLOD
getObjectLODModel
and getObjectModelOfLOD
getObjectLODOfModel
and getObjectModelOfLOD
The provided LOD model list not only is incomplete, it also contains plain incorrections. Examples are the LLODs for HLOD models 10428, 10369, 10439. |
I'm surprised, I thought the list was generated from the game files not missing anything. Will you suggest a fix for the array? |
Just a note: |
I'm gonna investigate the HLOD => LLOD array. @lotsofs @spooky-spook
It's interesting that PS2 and XBOX versions of the games have different world mapping, but I think this is out of the scope of this LLOD-improvements PR.
|
Check it out so far, ive redone some functions. Moved things to model related files. Added isValidModel (general purpose func) @TheNormalnij I added model id checks, and also made it reset in engineFreeModel and when model manager is unloaded. Is this ok? |
CLuaCFunctions::AddFunction(name, func); | ||
} | ||
|
||
bool CLuaModelDefs::IsValidModel(std::string modelPurpose, std::uint32_t id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about an enum instead of string?
|
||
bool CLuaModelDefs::SetModelLOD(std::string modelPurpose, std::uint32_t hLODModel, std::uint32_t lLODModel) | ||
{ | ||
if (!(modelPurpose == "object" || modelPurpose == "building")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(modelPurpose != "object" && modelPurpose != "building")
|
||
constexpr std::size_t OBJ_LOD_MODELS_COUNT = 4289; | ||
constexpr std::pair<std::uint32_t, std::uint32_t> OBJ_LOD_MODELS_ARRAY[] = { | ||
{694, 784}, // sm_redwoodgrp => lod_redwoodgrp (countryS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe too much spacing before the comment?
{X, Y}, // comment
instead of
{X, Y}, // comment
{13804, 13808}, // cuntelandf4 => lodcuntelandf4 (LAhills) | ||
{13805, 13807}, // celalandbiv => lodcelalandbiv (LAhills) | ||
{13809, 13811}, // ce_grndpalcst02 => lodcepalcst02 (LAhills) | ||
{13810, 13812}, // ce_grndpalcst05 => lodce_grndpalcst05 (LAhills) | ||
{13813, 13815}, // cegraveblok03e => lodcegraveblok03e (LAhills) | ||
{13814, 13787}, // ceroadn => lodceroadn (LAhills) | ||
{13816, 13877}, // ce_safeground => ce_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need that?
Any other news? This PR is interesting! |
These functions should be shared, like setLowLODElement is. e.g: if you would like to create object on server-side, and get it's LOD model directly. |
What is missing for this PR to be completed? |
Any updates on this? @Fernando-A-Rocha |
I'll get back to this PR soon. There are several ways to approach the problem of LODs. We certainly need something that is both clientside and serverside due to createObject, createBuilding (soon available serverside) and setLowLodElement being shared functions... |
I am back with my manually built list of HLOD vs LLODs, using the removeWorldObject feature from the editor on every object in the map, and where that failed finding a manual match using the IDE list on the wiki or similar. Here are my conclusions, and more importantly, things that I think should be changed in the big table in CLodModels.cpp: Missing entries
HLODs using the same LLOD
multiple LLODs belonging to the same HLOD
Furthermore there is this entry: but it has other issues (read below)
LLODs that cover multiple HLODs Existing entry: Incorrect entries Existing entry: Actually upon second thought, these are probably yet another cases of LLODs that cover multiple HLODs, but I already marked them as plainly incorrect and I can't be bothered rewriting. LLOD to a LLOD Oddities that require subjective review Existing entry I dont have time to write the last entry, so here's my raw notes: I'd submit my suggested changes myself, but I have no idea how to do a pull request to a pull request. |
Wow thank you for your detailed review @lotsofs |
These are all objects that gave me trouble deleting them in the editor, their LLOD would still show after deletion, and I had to manually find their LLODs in the IDE list. Assuming for this same reason they were also missing from the table in CLodModels.cpp
These objects all use LLOD 17749, in addition to the already included HLOD 17559
These objects all appear the same HLOD, but have different LLODs for some reason: Inclusion recommended if it is desired that a user can request a HLOD belonging to a specific LLOD. (not including entry oilderricklod01 that is already in the table) !!!! This will complicate lookups for a HLOD to a LLOD. Might need to adjust some code to return a table instead, or just have it pick one.
7243 => 6996 was correct, but LLOD 6996 covers both HLODs 6994 and 7243 combined. The former is an entire casino building, and the latter is only the hedges surrounding its parking lot. A second opinion might be needed on what to do with this, but I'd heavily recommend changing the line as it makes much more sense after a visual inspectation.
HLOD 3412 is only the orange upper parts of a bridge, whereas HLOD 3411 is the entire bridge, including yet even more orange upper parts. LLOD 3413 matches HLOD 3411 much more closely
HLOD 5786 comprises just a set of door that go on entire building HLOD 5784 that LLOD 5945 matches much more closely. !!!! However, the LLOD seems to be rotated 180 degrees compared to the HLOD 5784. Someone else besides me should look at this and make a judgement call.
I let the invitation expire by accident, but I have managed to submit PRs to your repo for each of my proposed changes. ======================================= There are a bunch of LLODs that fit their HLOD rather awkwardly, such as being rotated in some way, or having additional structures like fences etc that are separated from the HLOD counterpart. I named like four above, but out of the thousands other entries there likely are more. This might lead to some minor visual impurities, but I personally don't think it significant enough to warrant investigation, as LLODs are not meant to be seen from up close either way. However it is something to make note of. |
Add missing entries to CLodModels.cpp
Add additional HLODs that each map to the same LLOD CLodModels.cpp
Add multiple LLODs for 1 HLOD to CLodModels.cpp
Update LLOD that covers multiple HLODs in CLodModels.cpp
Fix one entry in CLodModels.cpp
Fix entry 5945 in CLodModels.cpp
Thank you for the contributions. I'll take a look! |
Important
HLOD = High Level of Detail (normal models the player sees when near)
LLOD = Low Level of Detail (models with less detail the player sees when far)
Details
Adds new clientside model utility & Level-Of-Detail(LOD) management functions
WIP
To be used in conjunction with:
createObject
/createBuilding
setLowLODElement
engineSetModelLODDistance
This solves the problem of having to include a Lua LOD_TABLE in every map's script, which has been happening for years (the map editor's LOD table happens to be incomplete as of submitting this PR), providing a simple solution to obtain an object's LLOD model ID in the code.
Related to multitheftauto/mtasa-resources#556
Examples
LLOD model of HLOD model ganghous03_LAx (3655) is lodganghous03_lax (3656).
Practical code examples:
WIP